$(document).ready   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 9
rs 9.6666
c 3
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A 0 7 2
1
if (!jQuery('.scw-cookie').hasClass('scw-cookie-out')) {
2
    jQuery(document).find('body').addClass('scw-cookie-in');
3
}
4
5
function scwCookieHide()
6
{
7
    jQuery.post(
8
        '/scwCookie/ajax.php',
9
        {
10
            action : 'hide'
11
        }
12
    ).done(function(data){
13
        if (data.hasOwnProperty('success') && data.success) {
14
            jQuery('.scw-cookie').addClass('scw-cookie-slide-out');
15
            jQuery(document).find('body').removeClass('scw-cookie-in');            
16
        }
17
18
        if (jQuery('.scw-cookie').hasClass('changed')) {
19
            location.reload();
20
        }
21
    });
22
}
23
24
function scwCookieDetails()
25
{
26
    jQuery('.scw-cookie-details').slideToggle();
27
}
28
29
function scwCookieToggle(element)
30
{
31
    jQuery(element).closest('.scw-cookie-toggle').find('input[type="checkbox"]').click();
32
}
33
34
function scwCookiePanelToggle()
35
{
36
    jQuery('.scw-cookie').removeClass('scw-cookie-out');
37
    if (jQuery(document).find('body').hasClass('scw-cookie-in')) {
38
        jQuery('.scw-cookie').addClass('scw-cookie-slide-out');
39
        jQuery(document).find('body').removeClass('scw-cookie-in');
40
    } else {
41
        jQuery('.scw-cookie').removeClass('scw-cookie-slide-out');
42
        jQuery(document).find('body').addClass('scw-cookie-in');
43
    }
44
}
45
46
jQuery(document).ready(function($){
47
    $('.scw-cookie-switch input').each(function(){
48
        if ($(this).prop('checked')) {
49
            $(this).closest('.scw-cookie-switch').addClass('checked');
50
        } else {
51
            $(this).closest('.scw-cookie-switch').removeClass('checked');
52
        }
53
    });
54
});
55
jQuery(document).on('change', '.scw-cookie-toggle input[type="checkbox"]', function(){
56
    jQuery(this).closest('.scw-cookie').addClass('changed');
57
    jQuery(this).closest('.scw-cookie-switch').toggleClass('checked');
58
    jQuery.post(
59
        '/scwCookie/ajax.php',
60
        {
61
            action : 'toggle',
62
            name   : jQuery(this).attr('name'),
63
            value  : jQuery(this).prop('checked')
64
        }
65
    ).done(function(data){
66
        if (data.hasOwnProperty('removeCookies')) {
67
            jQuery.each(data.removeCookies, function(key, cookie){
68
                Cookies.remove(cookie.name);
0 ignored issues
show
Bug introduced by
The variable Cookies seems to be never declared. If this is a global, consider adding a /** global: Cookies */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
69
                Cookies.remove(cookie.name, { domain: cookie.domain });
70
                Cookies.remove(cookie.name, { path: cookie.path });
71
                Cookies.remove(cookie.name, { domain: cookie.domain, path: cookie.path });
72
            });
73
        }
74
    });
75
});
76
77
jQuery(document).ready(function($){
78
    $('.scw-cookie-tooltip-trigger').hover(function(){
79
        var label = $(this).attr('data-label');
80
        $(this).append('<span class="scw-cookie-tooltip">'+label+'</span>');
81
    }, function(){
82
        $(this).find('.scw-cookie-tooltip').remove();
83
    });
84
});
85
86
jQuery(document).ready(function($){
0 ignored issues
show
Unused Code introduced by
The parameter $ is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
87
    jQuery.post(
88
        '/scwCookie/ajax.php',
89
        {
90
            action : 'load',
91
        }
92
    ).done(function(data){
93
        if (data.hasOwnProperty('removeCookies')) {
94
            jQuery.each(data.removeCookies, function(key, cookie){
95
                Cookies.remove(cookie.name);
0 ignored issues
show
Bug introduced by
The variable Cookies seems to be never declared. If this is a global, consider adding a /** global: Cookies */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
96
                Cookies.remove(cookie.name, { domain: cookie.domain });
97
                Cookies.remove(cookie.name, { path: cookie.path });
98
                Cookies.remove(cookie.name, { domain: cookie.domain, path: cookie.path });
99
            });
100
        }
101
    });
102
});
103